package com.catchman.quartz.job;

import com.catchman.controller.common.SysController;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * @author CatchMan
 */
@Component
public class BackUpDbJob extends QuartzJobBean {
    @Autowired
    SysController sysController;
    private static final Logger logger = LoggerFactory.getLogger(BackUpDbJob.class);

    @Override
    protected void executeInternal(JobExecutionContext context) {
        try {
            if (sysController.backUpDataBase()) {
                logger.info("operation: {}", "成功定时备份数据库！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("operation: {},cause:{}", "定时备份数据库失败！", e.getLocalizedMessage());
        }
    }

}